package com.paotui.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.paotui.mapper.UsersMapper;
import com.paotui.pojo.Users;
import com.paotui.service.UsersService;
import com.paotui.util.SqlSessionFactoryUtil;
import lombok.Getter;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

@Getter
public class UsersServiceImpl extends ServiceImpl<UsersMapper, Users> implements UsersService {
    // 手动创建 Mapper
    // 后台服务器启动时就需要创建连接池，所以需要监听器来监听服务器状态
    SqlSession sqlSession = null;
    @Override
    public UsersMapper getBaseMapper() {
        sqlSession = SqlSessionFactoryUtil.getFactory().openSession(true);
        UsersMapper mapper = SqlSessionFactoryUtil.getFactory().getConfiguration().getMapper(UsersMapper.class,sqlSession);
        return mapper;
    }

    /*
    @Override
    public List<Users> queryAllInfo() {
       return this.getBaseMapper().queryAllInfo();
    }
    */
}
